package me.zhengjie.config;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * 苏州行政区枚举
 */
@Getter
@AllArgsConstructor
public enum DistrictEnum {

    SUZHOU_HUQIU("苏州市", "虎丘区", new BigDecimal("120.4393816"), new BigDecimal("31.345372"), new BigDecimal("83.2")),
    SUZHOU_GUSU("苏州市", "姑苏区", new BigDecimal("120.587367"), new BigDecimal("31.315648"), new BigDecimal("92.4")),
    SUZHOU_WUZHONG("苏州市", "吴中区", new BigDecimal("120.632094"), new BigDecimal("31.253604"), new BigDecimal("138.9")),
    SUZHOU_WUJIANG("苏州市", "吴江区", new BigDecimal("120.645728"), new BigDecimal("31.138025"), new BigDecimal("154.5")),
    SUZHOU_XIANGCHENG("苏州市", "相城区", new BigDecimal("120.632391"), new BigDecimal("31.395189"), new BigDecimal("89.1")),
    SUZHOU_GONGYEYUANQU("苏州市", "工业园区", new BigDecimal("120.747093"), new BigDecimal("31.322206"), new BigDecimal("113.3")),

    Changzhou_ZhongLou("常州市", "钟楼区", new BigDecimal("120.4393816"), new BigDecimal("31.345372"), new BigDecimal("83.2")),
    Changzhou_WuJin("常州市", "武进区", new BigDecimal("120.587367"), new BigDecimal("31.315648"), new BigDecimal("92.4")),
    Changzhou_XinBei("常州市", "新北区", new BigDecimal("120.632094"), new BigDecimal("31.253604"), new BigDecimal("138.9")),
    Changzhou_TianNing("常州市", "天宁区", new BigDecimal("120.645728"), new BigDecimal("31.138025"), new BigDecimal("154.5")),
    Changzhou_JinTan("常州市", "金坛区", new BigDecimal("120.632391"), new BigDecimal("31.395189"), new BigDecimal("89.1")),
    Changzhou_LiYang("常州市", "溧阳市", new BigDecimal("120.747093"), new BigDecimal("31.322206"), new BigDecimal("113.3"));

    public final String city;//城市
    public final String district;//行政区
    //火星坐标系的经纬度
    public final BigDecimal lng;//经度
    public final BigDecimal lat;//纬度
    public final BigDecimal population;//人口（万人）

    public static final Map<String, DistrictEnum> districtMap = new HashMap<>();
    static{
        for (DistrictEnum districtEnum: DistrictEnum.values()) {
            String key = getKey(districtEnum.getCity(), districtEnum.getDistrict());
            districtMap.put(key, districtEnum);
        }
    }

    public static DistrictEnum getByDistrictName(String city, String name) {
        return districtMap.get(getKey(city, name));
    }

    private static String getKey(String city, String district) {
        return city + ":" + district;
    }

}
